<template>
  <div class="dashboard-container">
    <div class="grid-container">
      <!-- 左侧大区域 -->
      <div class="grid-item large-chart-item">
        <chart4 :table-data="tableData"/>
      </div>
      <!-- 右侧上区域 -->
      <div class="grid-item small-chart-item top-chart">
        <chart5/> 
      </div>
      <!-- 右侧下区域 -->
      <div class="grid-item small-chart-item bottom-chart">
        <chart6 :table-data="tableData"/>
      </div>
    </div>
  </div>
</template>

<script setup>
import chart4 from './component/chart4.vue'
import chart5 from './component/chart5.vue'
import chart6 from './component/chart6.vue'
import { getRegionDataList } from '@/api/flaud/regiondata'
import { ref, onMounted } from 'vue';

const page = ref(0)
const total = ref(0)
const pageSize = ref(0)
const tableData = ref([])
const searchInfo = ref({})

onMounted(() => {
  getTableData()
})

const getTableData = async () => {
  const table = await getRegionDataList({ page: page.value, pageSize: pageSize.value, ...searchInfo.value })
  if (table.code === 0) {
    tableData.value = table.data.list
    total.value = table.data.total
    page.value = table.data.page
    pageSize.value = table.data.pageSize
  }
  console.log(tableData.value)
}
</script>

<style scoped>
.dashboard-container {
  width: 100%;
  height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  overflow: auto;
}

.grid-container {
  display: grid;
  grid-template-columns: 3fr 2fr; /* 左侧2份，右侧1份 */
  grid-template-rows: 1fr 1fr; /* 两行等高 */
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  height: calc(100vh - 40px);
}

.grid-item {
  border-radius: 12px;
  background: white;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  position: relative;
}

.large-chart-item {
  grid-row: 1 / span 2; /* 占据两行 */
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(to bottom right, #ffffff, #f8f9fa);
}

.small-chart-item {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(to bottom right, #ffffff, #f8f9fa);
}

.top-chart {
  grid-column: 2;
  grid-row: 1;
}

.bottom-chart {
  grid-column: 2;
  grid-row: 2;
}

.grid-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
  border-radius: 12px 12px 0 0;
}

.grid-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.05);
}

.grid-item > * {
  width: 100%;
  height: 100%;
  padding: 15px;
  box-sizing: border-box;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .grid-container {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(3, auto);
    height: auto;
  }
  
  .large-chart-item,
 .small-chart-item {
    grid-column: 1;
  }
  
  .top-chart { grid-row: 1; }
  .bottom-chart { grid-row: 2; }
  .large-chart-item { grid-row: 3; }
  
  .dashboard-container {
    height: auto;
    min-height: 100vh;
  }
}

/* 动画效果 */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.grid-item:nth-child(1) { animation: fadeIn 0.6s ease-out; }
.grid-item:nth-child(2) { animation: fadeIn 0.6s ease-out 0.1s forwards; }
.grid-item:nth-child(3) { animation: fadeIn 0.6s ease-out 0.2s forwards; }
</style>